<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/node.css" />
		<style type="text/css">

		</style>
	</head>

	<body>

		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<span class="mui-icon mui-icon-search mui-pull-left" style="margin: 2px;"></span>
			<input id="search" type="search" placeholder="" style=" margin: 8px 0px; width: 60%; right: 20%; position: absolute;">
		</header>

		<div id="list" class="mui-content">
			<div id="item">
				<div class="node-frame">
					<div style="height: 100px;">
						<img id="img" class="node-img" src="../img/shuijiao.jpg" height="100%" align="right">
						<div id="theme" class="node-theme">bbbb</div>
					</div>
				</div>
			</div>
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../json/data1.js"></script>
		<script src="../js/http.js"></script>

		<script type="text/javascript">
			var search = document.getElementById("search");
			var list = document.getElementById("list");
			var item = document.getElementById("item");
			search.addEventListener("search", onSearch);
			item.style.display = 'none';

			function onSearch() {
				search.blur();

				for(var i = 0; i < data1.length; i++) {
					var o = data1[i];
					var div = item.cloneNode(true)
					var theme = div.querySelector("#theme");
					var img = div.querySelector("#img");
					theme.textContent = o.title;
					img.src = o.img[0];
					list.appendChild(div);
					div.style.display = 'inline';
					div.name = o.id;
					div.addEventListener("click", function() {
						mui.openWindow("details.html", this.name);
					});
				}
				list.focus();
			}

			mui.init({
				swipeBack: true //启用右滑关闭功能
			});

			var nativeWebview, imm, InputMethodManager;
			var initNativeObjects = function() {
				if(mui.os.android) {
					var main = plus.android.runtimeMainActivity();
					var Context = plus.android.importClass("android.content.Context");
					InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
					imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
				} else {
					nativeWebview = plus.webview.currentWebview().nativeInstanceObject();
				}
			};
			var showSoftInput = function() {
				if(mui.os.android) {
					imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
				} else {
					nativeWebview.plusCallMethod({
						"setKeyboardDisplayRequiresUserAction": false
					});
				}
				setTimeout(function() {
					search.focus();
				}, 1000);
			};
			mui.plusReady(function() {
				initNativeObjects();
				showSoftInput();
			});
		</script>
	</body>

</html>